﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TomanuExtensions;

namespace RaytracerLib.Script
{
    internal static class ScriptUtils
    {
        public static string Wrap(string a_script)
        {
            if (!a_script.StartsWith(Environment.NewLine))
                a_script = Environment.NewLine + a_script;
            if (!a_script.EndsWith(Environment.NewLine))
                a_script = a_script + Environment.NewLine;

            return a_script;
        }

        public static string Unwrap(string a_script)
        {
            while (a_script.StartsWith(Environment.NewLine))
                a_script = a_script.RemoveFromLeft(Environment.NewLine.Length);
            while (a_script.StartsWith("\n"))
                a_script = a_script.RemoveFromLeft(1);
            while (a_script.EndsWith(Environment.NewLine))
                a_script = a_script.RemoveFromRight(Environment.NewLine.Length);
            while (a_script.EndsWith("\n"))
                a_script = a_script.RemoveFromRight(1);

            return a_script;
        }
    }
}
